/*     */ package com.qmsk.business.store.groupdictrule.controller;
/*     */ 
/*     */ import com.qmsk.business.store.groupdictrule.dao.GroupDictRuleDAO;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"groupDictRule"})
/*     */ public class GroupDictRuleController
/*     */ {
/*  42 */   private static final Logger logger = Logger.getLogger(GroupDictRuleController.class);
/*     */ 
/*     */   @Autowired
/*     */   private GroupDictRuleDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  52 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  54 */       Map params = new HashMap();
/*  55 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*  56 */       MapUtils.addToMap(params, "status", 
/*  57 */         RequestUtils.getInt(request, "status"));
/*  58 */       MapUtils.addPercentToMap(params, "name", 
/*  59 */         RequestUtils.getString(request, "name"));
/*  60 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  61 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  63 */       logger.error(e);
/*  64 */       ResponseUtils.setErrorMsgResponse(
/*  65 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/*  73 */       Map params = new HashMap();
/*  74 */       MapUtils.addToMap(params, "id", id);
/*  75 */       MapUtils.addToMap(params, "status", 
/*  76 */         RequestUtils.getInt(request, "status"));
/*  77 */       MapUtils.addPercentToMap(params, "name", 
/*  78 */         RequestUtils.getString(request, "name"));
/*  79 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(params);
/*  80 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  82 */       logger.error(e);
/*  83 */       ResponseUtils.setErrorMsgResponse(
/*  84 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 102 */       int nResult = 0;
/* 103 */       String sData = RequestUtils.getStringOfData(request);
/* 104 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*     */ 
/* 106 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 107 */         nResult = this.dao.applyUpdates(p);
/* 108 */         if (nResult > 0)
/* 109 */           DbConnection.commit();
/*     */         else {
/* 111 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 114 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 115 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 116 */         response);
/*     */     } catch (Exception e) {
/* 118 */       logger.error(e);
/* 119 */       DbConnection.rollback();
/* 120 */       ResponseUtils.setErrorMsgResponse(
/* 121 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 122 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}/{id}/{sendRange}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("id") Long id, @PathVariable("sendRange") Integer sendRange)
/*     */   {
/*     */     try
/*     */     {
/* 141 */       int nResult = 0;
/* 142 */       String sData = RequestUtils.getStringOfData(request);
/* 143 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 144 */       if ((p != null) && (p.isExistsUpdateRows())) {
/* 145 */         if (((GsonHeadOneRow)p.getListUpdateRows().get(0)).getValueOfName("id") == null) {
/* 146 */           ((GsonHeadOneRow)p.getListUpdateRows().get(0)).autoAddHeadData("id", id);
/*     */         }
/*     */ 
/* 149 */         nResult = this.dao.applyUpdates(p);
/* 150 */         if (nResult > 0)
/* 151 */           DbConnection.commit();
/*     */         else {
/* 153 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 156 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 157 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 158 */         response);
/*     */     } catch (Exception e) {
/* 160 */       logger.error(e);
/* 161 */       DbConnection.rollback();
/* 162 */       ResponseUtils.setErrorMsgResponse(
/* 163 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 164 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 180 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 182 */       String[] strParams = id.split(",");
/* 183 */       int nResult = this.dao.deleteParams(strParams);
/* 184 */       if (nResult > 0)
/* 185 */         DbConnection.commit();
/*     */       else {
/* 187 */         DbConnection.rollback();
/*     */       }
/* 189 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 190 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 191 */         response);
/*     */     } catch (Exception e) {
/* 193 */       DbConnection.rollback();
/* 194 */       logger.error(e);
/* 195 */       ResponseUtils.setErrorMsgResponse(
/* 196 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 197 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.groupdictrule.controller.GroupDictRuleController
 * JD-Core Version:    0.5.3
 */